//package com.mediacloud.app.newsmodule.activity.microlive
//
//import android.os.Bundle
//import android.view.View
//import android.view.ViewStub
//import android.widget.ImageView
//import androidx.fragment.app.Fragment
//import androidx.fragment.app.FragmentActivity
//import androidx.lifecycle.Observer
//import androidx.recyclerview.widget.LinearLayoutManager
//import androidx.recyclerview.widget.RecyclerView
//import androidx.viewpager.widget.ViewPager
//import com.androidkun.xtablayout.XTabLayout
//import com.jeremyliao.liveeventbus.LiveEventBus
//import com.mediacloud.app.assembly.util.AssetsManager
//import com.mediacloud.app.assembly.util.Utility
//import com.mediacloud.app.cloud.ijkplayersdk.video.VideoPlayer
//import com.mediacloud.app.model.news.ArticleItem
//import com.mediacloud.app.model.utils.DefaultBgUtil
//import com.mediacloud.app.model.view.WebViewVideoPlay
//import com.mediacloud.app.model.view.WebViewVideoPlayEvent
//import com.mediacloud.app.newsmodule.R
//import com.mediacloud.app.newsmodule.activity.microlive.MicroLiveDetailActivity.VideoPlayerListenerImplX
//import com.mediacloud.app.newsmodule.fragment.comment.MicroCommentFragment
//import com.mediacloud.app.newsmodule.fragment.imagetext.ImageTextDetailFragment
//import com.mediacloud.app.newsmodule.fragment.imagetext.MicroImageTextDetailFragment
//import com.mediacloud.app.newsmodule.view.CommentPopupWindow
//import java.util.*
//
//class MicVideoUtil(val context: FragmentActivity, rootView: View, val articleItem: ArticleItem) {
//    var viewPager: ViewPager
//    var player: VideoPlayer
//    var tabLayout: XTabLayout
//    var loadingView: View
//
//    //多机位列表
//    var cameraListView: RecyclerView
//
//    //多机位列表适配器
//    var itemVideoAdapter: ItemVideoAdapter
//    var microLiveTableAdaptor: MicroLiveTableAdaptor
//
//    //图文直播Web页面
//    var microLiveWebviewFragment: MicroLiveWebviewFragment
//
//    //直播介绍
//    var imageTextDetailFragment: MicroImageTextDetailFragment
//    var orderImage: ImageView
//
//    init {
//        rootView.findViewById<ViewStub>(R.id.view_stub_micro_live_type_player).inflate()
//        viewPager = rootView.findViewById(R.id.viewPager)
//        tabLayout = rootView.findViewById(R.id.tableLayout)
//        loadingView = rootView.findViewById(R.id.loadingView)
//        cameraListView = rootView.findViewById(R.id.appfacViewId)
//        player = rootView.findViewById(R.id.player)
//        player.timeLabelShowHour = true
//        player.hideButtonBack()
//        LiveEventBus.get(WebViewVideoPlayEvent, WebViewVideoPlay::class.java).observe(context, Observer { player.pause() })
//        val fragmentList = ArrayList<Fragment>()
//        //直播介绍
//        imageTextDetailFragment = MicroImageTextDetailFragment()
//        val bundle = Bundle()
//        bundle.putBoolean(ImageTextDetailFragment.FROM_MICROLIVE, true)
//        bundle.putParcelable("data", articleItem)
//        bundle.putParcelable("catalog", catalogItem)
//        imageTextDetailFragment.arguments = bundle
//        //评论
//        val newsCommentFragment = MicroCommentFragment()
//        val commentBundle = Bundle()
//        commentBundle.putParcelable("data", articleItem)
//        commentBundle.putBoolean("appfac", true)
//        newsCommentFragment.arguments = commentBundle
//
//        // 图文直播
//        microLiveWebviewFragment = MicroLiveWebviewFragment(content)
//        val microLiveBundle = Bundle()
//        microLiveBundle.putParcelable("data", articleItem)
//        microLiveWebviewFragment.arguments = microLiveBundle
//
//
//        fragmentList.add(imageTextDetailFragment)
//        fragmentList.add(newsCommentFragment)
//        fragmentList.add(microLiveWebviewFragment)
//
//        microLiveTableAdaptor = MicroLiveTableAdaptor(context.supportFragmentManager, fragmentList)
//
//        microLiveTableAdaptor.titile.put(microLiveTableAdaptor.titile.size(), context.resources.getString(R.string.jianjie))
//        microLiveTableAdaptor.titile.put(microLiveTableAdaptor.titile.size(), context.resources.getString(R.string.micro_comment))
//        microLiveTableAdaptor.titile.put(microLiveTableAdaptor.titile.size(), context.resources.getString(R.string.micro_tuwenzhibo))
//        orderImage = Utility.findViewById<ImageView>(mRootView, R.id.order_image)
//        orderImage.setOnClickListener(this)
//        viewPager.offscreenPageLimit = fragmentList.size
//        viewPager.addOnPageChangeListener(object : ViewPager.OnPageChangeListener {
//            override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {}
//            override fun onPageSelected(position: Int) {
//                tabLayout.getTabAt(position)!!.select()
//                if (position == 2) {
//                    orderImage.setVisibility(View.VISIBLE)
//                } else {
//                    orderImage.setVisibility(View.GONE)
//                }
//                setOrderImageSrc()
//            }
//
//            override fun onPageScrollStateChanged(state: Int) {}
//        })
//        viewPager.adapter = microLiveTableAdaptor
//        tabLayout.setupWithViewPager(viewPager)
//        tabLayout.setTabTextColors(getResources().getColor(R.color.appfac_microlive_jinan), DefaultBgUtil.getTintColor(this))
//        tabLayout.setSelectedTabIndicatorColor(DefaultBgUtil.getTintColor(this))
//        viewPager.currentItem = 1
//        itemVideoAdapter = ItemVideoAdapter(this, player)
//        val linearLayoutManager = LinearLayoutManager(this)
//        linearLayoutManager.orientation = LinearLayoutManager.HORIZONTAL
//        cameraListView.layoutManager = linearLayoutManager
//        cameraListView.adapter = itemVideoAdapter
//        cameraListView.visibility = View.GONE
//        player.toggleFullScreenEnable(false)
//        player.setTopControlViewVisible(View.GONE)
//        player.setvideoQualityTitleViseble(View.GONE)
//        val pausewebviewvideo = AssetsManager.getTextFromAssetsFile(this, "web/pausewebviewvideo.txt")
//        player.setOnPlayerListener(object : VideoPlayerListenerImplX() {
//            override fun oncomplete(currentMediaIndex: Int) {
//                super.oncomplete(currentMediaIndex)
//                showPlayerView(false)
//            }
//
//            override fun onVideoTimeUpdate(position: Int, duration: Int) {
//                super.onVideoTimeUpdate(position, duration)
//            }
//        })
//         player.showVideoTitleInfo(articleItem.getTitle())
//        itemVideoAdapter.itemClickListener = this
//        commentDialogFram.commentListener = object : CommentPopupWindow.SubmitCommentListener {
//            override fun success() {
//                newsCommentFragment.onRefresh()
//            }
//
//            override fun failed() {}
//        }
//    }
//
//
//}